package com.basic.domain;

import lombok.Builder;
import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 分页参数返回
 */
@Data
@Accessors(chain = true)
@Builder
public class PageResult<T> implements Serializable {


    // 总数量
    private long totalElements;

    // 内容
    private List<T> content;

    public PageResult(long totalElements, List<T> content) {
        this.totalElements = totalElements;
        this.content = content;
    }

    public PageResult() {
    }

    public Map<String, Object> map(){
        final Map<String, Object> result = new HashMap<>();
        result.put("content", content);
        result.put("totalElements", totalElements);
        return result;
    }
}
